package com.example.PolimiAssistant.common;

import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import com.example.PolimiAssistant.ExamSchedule_detail;
import com.example.PolimiAssistant.R;
import com.example.PolimiAssistant.MessageActivity;

/**
 * Created by Vlado on 01.07.2014.
 */
public class ReminderService  extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent paramIntent) {
    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    Intent intent = new Intent(context, MessageActivity.class);

    String course_name = paramIntent.getStringExtra("course_exam_name");
    Integer id =  paramIntent.getIntExtra("course_exam_id",0);
        intent.putExtra("course_exam_name", course_name);
        intent.putExtra("course_exam_id",id);
        intent.putExtra("course_exam_start_reg", paramIntent.getStringExtra("course_exam_start_reg"));
        intent.putExtra("course_exam_stop_reg", paramIntent.getStringExtra("course_exam_stop_reg"));
        intent.putExtra("course_exam_date", paramIntent.getStringExtra("course_exam_date"));
        intent.putExtra("course_exam_classroom", paramIntent.getStringExtra("course_exam_classroom"));


    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    Notification.Builder mbuilder = new Notification.Builder(context);
    mbuilder.setSmallIcon(R.drawable.classroom)
            .setContentTitle("Exam Registration")
            .setContentText(course_name)
            .setDefaults(Notification.DEFAULT_SOUND)
            .setAutoCancel(false);

    mbuilder.setContentIntent(pendingIntent);

    notificationManager.notify(id, mbuilder.build());

    }
}
